﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EAILogWebSite.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index(int? pn)
        {
            int currentPage = 1;
            if (pn.HasValue)
                currentPage = pn.Value;

            var result = new EAIDBEntities().Table_Log.OrderByDescending(x => x.Id);
            ViewData["TotalPage"] = (result.Count() - 1) / 40 + 1;
            ViewData["CurrentPage"] = currentPage;



            return View(result.Skip(((currentPage - 1) * 40)).Take(40));
        }

        public ActionResult Detail(int id)
        {
            var log = new EAIDBEntities().Table_Log.FirstOrDefault(x => x.Id == id);

            return View(log);
        }


        public ActionResult Test()
        {
            return View();
        }
    }
}
